Inside Macintosh: Memory

Previous | Chapter Top | Chapter Contents | Next

Manipulating Blocks of Memory

The Memory Manager provides a routine for copying blocks of memory referenced by pointers. To copy a block of memory to a nonrelocatable block, you can use the BlockMove procedure.

BlockMove

To copy a sequence of bytes from one location in memory to another, you can use the BlockMove procedure.

PROCEDURE BlockMove (sourcePtr, destPtr: Ptr; byteCount: Size);
sourcePtr
The address of the first byte to copy.
destPtr
The address of the first byte to copy to.
byteCount
The number of bytes to copy. If the value of byteCount is 0, BlockMove does nothing.

DESCRIPTION

The BlockMove procedure moves a block of byteCount consecutive bytes from the address designated by sourcePtr to that designated by destPtr . It updates no pointers.

The BlockMove procedure works correctly even if the source and destination blocks overlap.

SPECIAL CONSIDERATIONS

You can safely call BlockMove at interrupt time. Even though it moves memory, BlockMove does not move relocatable blocks, but simply copies bytes.

The BlockMove procedure currently flushes the processor caches whenever the number of bytes to be moved is greater than 12. This behavior can adversely affect your application's performance. You might want to avoid calling BlockMove to move small amounts of data in memory if there is no possibility of moving stale data or instructions. For more information about stale data and instructions, see the discussion of the processor caches in the chapter "Memory Management Utilities" in this book.

ASSEMBLY-LANGUAGE INFORMATION

The registers on entry and exit for BlockMove are

Registers on entry

A0

Pointer to source

A1

Pointer to destination

D0

Number of bytes to copy

Registers on exit

D0

Result code

RESULT CODE

noErr

0

No error


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next